
package com.buaa.hyf.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;

import com.buaa.hyf.adapter.StageAdapter;
import com.buaa.hyf.util.Globals;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class MainActivity extends AppCompatActivity {

    private GridView grid;
    private List<Map<String,Object>> values;
    private StageAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Globals.init(this);
        setContentView(R.layout.activity_main);

        grid = (GridView) findViewById(R.id.grid);
        values = new ArrayList<>();

        for (int i = 1;i<=50;i++){
            Map<String,Object> map = new HashMap<>();
            map.put("stage_num",i);
            if(i<10){
                map.put("overFlag",true);
            }else{
                map.put("overFlag",false);
            }
            values.add(map);
        }
        adapter = new StageAdapter(values,this);
        grid.setAdapter(adapter);

        grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Map<String,Object> map = values.get(position);
                if((Boolean)map.get("overFlag")){
                    Toast.makeText(MainActivity.this,"已玩儿过",Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(MainActivity.this,"没玩儿呢还",Toast.LENGTH_SHORT).show();
                }
            }
        });
    }


}
